package com.yidu.t299.dao.ssk;
import com.yidu.t299.domain.ssk.ChargeBacktrack;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author 粟术康
 * @version 1.0
 * @description
 * @date:2023/3/11 17:37
 */
@Mapper
public interface ChargeBacktrackMapper {
    /**
     * 添加退费信息
     * @param chargeBacktrack 退费对象
     * @return 影响的行数(返回1则为成功)
     */
    @Insert({"insert into charge_backtrack (charge_criterion_id,charge_criterion_item,charge_standard)" +
            " values " +
            "(#{chargeCriterionId,jdbcType=INTEGER}, " +
            "#{chargeCriterionItem,jdbcType=VARCHAR}," +
            "#{chargeStandard,jdbcType=VARCHAR})"
    })
    int insert(ChargeBacktrack chargeBacktrack);
    /**
     * 根据退费编号删除该退费信息
     * @param chargeCriterionId 退费编号
     * @return 影响的行数(返回1则为成功)
     */
    @Delete({"delete from charge_backtrack" +
            " where charge_criterion_id = #{chargeCriterionId,jdbcType=INTEGER}"})
    int deleteByPrimaryKey(Integer chargeCriterionId);
    /**
     * 根据退费信息修改其数据
     * @param chargeBacktrack 退费对象
     * @return 影响的行数(返回1则为成功)
     */
    @Update({
            "update charge_backtrack" +
                    " set charge_criterion_item = #{chargeCriterionItem,jdbcType=VARCHAR}," +
                    " charge_standard = #{chargeStandard,jdbcType=VARCHAR}" +
                    " where charge_criterion_id = #{chargeCriterionId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ChargeBacktrack chargeBacktrack);
    /**
     * 根据退费编号查询指定的信息
     * @param chargeCriterionId 退费编号
     * @return 退费对象
     */
    @Select({
            "select" +
                    " charge_criterion_id,charge_criterion_item,chargeStandard" +
                    " from charge_backtrack" +
                    " where charge_criterion_id = #{chargeCriterionId,jdbcType=INTEGER}"
    })
    @Results(id = "ChargeBacktrackMap",value = {
            @Result(id = true,column = "charge_criterion_id",property = "chargeCriterionId" ),
            @Result(column = "charge_criterion_item",property = "chargeCriterionItem"),
            @Result(column = "charge_standard",property = "chargeStandard")
    })

    ChargeBacktrack selectByPrimaryKey(Integer chargeCriterionId);

    /**
     * 按条件分页查询退费数据集合
     * @param rows 每页的行数
     * @param page 页码
     * @param condition 条件参数
     * @return 退费对象集合
     */
    @Select("select * from charge_backtrack where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("ChargeBacktrackMap")
    List<ChargeBacktrack> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 按条件查询chargeBacktrack表中数据行数
     * @param condition 条件参数
     * @return 数据行数
     */
    @Select("select count(*) from charge_backtrack where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);
}
